package cn.org.xiaosheng.aspect;

import cn.org.xiaosheng.annotation.ChangeLog;
import cn.org.xiaosheng.enums.PlatformTypeEnum;
import cn.org.xiaosheng.strategy.context.SolverChooser;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class ChangeLogAspect {

    @Autowired
    private SolverChooser solverChooser;

    @Pointcut("@annotation(cn.org.xiaosheng.annotation.ChangeLog)")
    public void pointcut(){}

    @Before("pointcut()")
    public void beforeMethod(JoinPoint joinPoint) {
        // 此处可以添加注解方法执行前的前置逻辑
    }

    @Around("pointcut()")
    public void aroundMethod(JoinPoint joinPoint) {
        // 此处可以添加注解方法执行的环绕逻辑
    }

    /**
     * 注解表示该方法是一个切面的后置返回通知，会在目标方法成功执行并返回结果后触发
     * @param joinPoint
     * @param result
     */
    @AfterReturning(value = "pointcut()", returning = "result")
    public void afterReturningMethod(JoinPoint joinPoint, Object result) {
        // 此处可以添加注解方法执行后的后置逻辑
    }

    @AfterThrowing(pointcut = "pointcut()", throwing = "e")
    public void afterThrowingMethod(JoinPoint joinPoint, Exception e) {
        // 此处可以添加注解方法执行异常后的后置逻辑
    }

}
